﻿using System.Collections.Generic;
using Com.OpenCode.Framework.Core;

namespace Com.OpenCode.Framework.Workbench
{
    public class PluginComparer : Comparer<Plugin>
    {
        public override int Compare(Plugin x, Plugin y)
        {
            int xIndex = 0;
            int yIndex = 0;
            if (x != null) int.TryParse(x.Properties.Get("Index").ToString(), out xIndex);
            if (y != null) int.TryParse(y.Properties.Get("Index").ToString(), out yIndex);
            if (xIndex == yIndex)
            {
                return 0;
            }
            if (xIndex > yIndex)
            {
                return 1;
            }
            return -1;
        }
    }
}